package com.ruoyi.crm.moulds.mq;

import com.ruoyi.crm.domain.Contract;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

import static com.ruoyi.crm.moulds.mq.CrmRabbitConfig.CRM_EXCHANGE_CONTRACT;
import static com.ruoyi.crm.moulds.mq.CrmRabbitConfig.CRM_ROUTING_KEY_CONTRACT_CREATED;

@Component
public class CrmProducer {
    @Resource
    private RabbitTemplate rabbitTemplate;

    public void produceContractCreatedMessage(Contract contract){
        rabbitTemplate.convertAndSend(CRM_EXCHANGE_CONTRACT,CRM_ROUTING_KEY_CONTRACT_CREATED,contract);
    }
}
